
<div class="row">
<div class="col-md-6 col-md-offset-3 col-sm-12" style="margin: 0 auto;float: none;">
<div class="ui-portlet clearfix ">	
     <div class="sign-inner">
                <div class="reg-header">            
			        <h2>{{__('Register')}}</h2>
			    </div>
{{if !$invite_user}}		    
	<h4>第三方账号免注册登录</h4>
	 <?php if(empty($_REQUEST['state']) && $_SERVER['HTTP_HOST']=='www.135plat.com') $_REQUEST['state']='135plat';?>
      <p>
      <a onclick="window.open('http://www.135editor.com/oauth/qq/login?state={{$_REQUEST['state']}}','qqlogin','height=500,width=800,top=120,left='+(window.screen.availWidth/2-400)+',help=no,resizable=no,status=no,scroll=no');" href="javascript:;" ><img style="height: 45px;" src="/img/oauth/icon-qq.png" title="使用QQ登陆" class="showtooltip" ></a>
      &nbsp;
      {{if Configure::read('Weixin.qrlogin') }}
      <a onclick="window.open('http://www.135editor.com/oauth/weixin/qrlogin?state={{$_REQUEST['state']}}','weixin_qrlogin','height=500,width=800,top=120,left='+(window.screen.availWidth/2-400)+',help=no,resizable=no,status=no,scroll=no');" href="javascript:;" >
      <img style="height: 45px;" src="/img/oauth/icon-wechat.png" title="使用微信登陆" class="showtooltip" >
      </a>
      {{/if}}
      </p>
      <hr style="margin: 15px 0;"/>
{{/if}}
      <h4>网站用户注册</h4>
                <!-- onsubmit="return ajaxSubmitForm(this);"  -->
                <form class="reg-block form-horizontal" role="form" id="register-form"  method="post" action="{{$this->Html->url('/users/register/'.$invite_code)}}" >
<style>
    {{if !$is_mobile}}
.reg-block {
    background: none repeat scroll 0 0 #fefefe;
    border: 1px solid #eee;box-shadow: 0 0 3px #eee;color: #555;padding:15px 15px;
}
.reg-block .input-group-addon {
    background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
    color: #bbb;min-width: 120px;text-align: left;
}
    {{/if}}

.reg-header {border-bottom: 1px solid #eee;color: #555;margin-bottom: 20px;text-align: center;}
</style>
                  <div class="form-group alert alert-danger help-block hidden" id="register_errorinfo"></div>  
                  
                  {{if $invite_user}}
                  <div class="form-group clearfix">
                        <label class="col-xs-3 control-label">邀请人</label>
                        <div class="col-xs-9">
                          <input type="text" readonly="readonly" name="invite_user" value="{{$invite_user['User']['username']}}" class="form-control">
                          <p style="color:red;">注册后，获赠一个月VIP会员。</p>
                        </div>
                  </div>
					<input type="hidden" readonly="readonly" name="invite_code" value="{{$invite_code}}">
                 <!-- <div class="form-group clearfix">
                        <label class="col-xs-3 control-label">邀请码</label>
                        <div class="col-xs-9">
                          <input type="text" readonly="readonly" name="invite_code" value="{{$invite_code}}" class="form-control">
                        </div>
                  </div> --> 
                  {{else}}
                  <div class="form-group clearfix"> 
                  	<div class="col-xs-12">
                  	<small style="color:red;">从135会员的朋友获取邀请注册链接，注册后，两人均获赠一个月VIP会员。如果找不到朋友邀请，可关注135编辑器订阅号获取。</small>
                  	</div>
                  </div>
                  {{/if}}


                  <div class="form-group clearfix">
                        <label class="col-xs-3 control-label" for="register-mobile">手机号</label>
                        <div class="col-xs-9">
                          <input type="text"  required="required" placeholder="输入您的手机号" name="data[User][mobile]"  id="register-mobile" maxlength="32"  class="form-control">
                          <div style="margin-top:5px;">
                          	<input style="display:inline-block;width:90px;" type="text" placeholder="图片验证码" class="form-control" minlength="4" maxlength="4" id="sms-captcha">
                        	<a href="javascript:void(0)" title="看不清，点击换一张" onclick="change_captcha();"><img style="height:38px;" id="register-captcha" src="{{$this->Html->url('/users/captcha')}}"/></a>
                        	<input type="button" class="btn btn-default" id="btn-send-msg" value="发送短信验证码" onclick="send_msg(this);">
                          </div>
                        </div>
                  </div>
                  
				<div class="form-group clearfix">
                        <label class="col-xs-3 control-label" for="register-mobile">验证码</label>
                        <div class="col-xs-9">
                          <input type="number"  required="required" placeholder="输入手机接收短信中的4位验证码" name="data[User][captcha]"  id="register-mobile" maxlength="4"  class="form-control">
                        </div>
                  </div>
                  <!-- 
                  <div class="form-group clearfix">
                        <label class="col-xs-3 control-label">{{__('Email')}}</label>
                        <div class="col-xs-9">
                          <input type="email"  required="required" onblur="checkemail(this)" placeholder="{{__('Email')}}" name="data[User][email]"  id="register-email" maxlength="32"  class="form-control">
                        </div>
                  </div>
                  -->
                  
                  <div class="form-group clearfix">
                        <label class="col-xs-3 control-label">{{__('Password')}}</label>
                        <div class="col-xs-9">
                          <input type="password"  required="required" placeholder="请输入网站登录密码" id="password"  class="form-control margin-bottom-xs" minlength="6" maxlength="15" name="data[User][password]">
                        </div>
                  </div>
                  <div class="form-group clearfix">
                        <label class="col-xs-3 control-label">{{__('Confirm Password')}}</label>
                        <div class="col-xs-9">
                          <input type="password" equalTo="#password"  required="required" placeholder="{{__('Confirm Password')}}" id="repeat-password" class="form-control" minlength="6" maxlength="15" name="data[User][password_confirm]">
                        </div>
                  </div>
                  
                  <!-- {{if empty($invite_user)}}
                  <div class="form-group">
                  	<div class="input-group">
                  		<span class="input-group-addon">
                  			邀请码
                  		</span>
                    	<input type="text"  name="invite_code" value="" class="form-control">
                	</div>
                  </div>                  
                  {{/if}} -->
                  <div>
                    <div>
                    
                      <input id="register-agree" style="margin:0 4px 0 0;" type="checkbox" name="data[User][agree]" required="required"> 
                      <label for="register-agree">{{__('agree_to_the_terms_service')}} </label>
                    </div>
                  </div>
                  <div>
                  <button class="btn btn-primary btn-block" type="submit">{{__('Register')}}</button>
                </div>
                
                <hr>
	            <div>
					<p>{{__('Have account?')}} &nbsp; {{$this->Html->link(__('Login'), array('controller' => 'users','action' => 'login' ),
						array('target'=>'_self'))}}</p>
					<div>{{$this->Hook->call('oauthLoginLink')}}</div>
				</div>
	            <div>{{$this->Hook->call('oauthLoginLink')}}</div>
{{$this->Html->script(array('jquery/jquery.validate.js','jquery/i18n/messages_zh.js',))}}
<script  type="text/javascript">
$(function(){
	$('#UserEmail').focus();
});
var lastusername = lastpassword = lastemail = lastinvitecode = '';

function change_captcha(){
	$('#register-captcha').attr('src','{{$this->Html->url('/users/captcha')}}?_='+randomString(8));
}
function send_msg(dom){
	var mobile = $('#register-mobile').val();
	var captcha = $('#sms-captcha').val();
	if(mobile == '') {
		showErrorMessage("请先输入手机号");$('#register-mobile').focus();return false;
	}
	else if(captcha == '') {
		showErrorMessage("请输入图片验证码后再点击发送短信验证码");$('#sms-captcha').focus();return false;
	}
	ajaxAction('/users/send_msg/0', {mobile:mobile,captcha:captcha},null,function(request){
		if(request.ret == 0){
			showSuccessMessage(request.msg);
			
			var time = 90;
			var send_msg_ti = setInterval(function(){				
				if(time > 0) {
					$('#btn-send-msg').attr('disabled','distabled');
					$('#btn-send-msg').val('再次发送('+time+'秒后)');
				}
				else{
					$('#btn-send-msg').removeAttr('disabled');
					$('#btn-send-msg').val('发送短信验证码');
					clearInterval(send_msg_ti);
				}
				time--;
			},1000);
			
		}
		else{
			showErrorMessage(request.msg);
			change_captcha();
		}
	});
}

function checkemail(obj) {
	var email = trim($(obj).val());
	if(email == '' || email == lastemail) {
		return;
	} else {
		lastemail = email;
	}
	ajaxAction('/users/checkemail?email=' + email, null,null,function(request){
		if(request.error){
			alert(request.error);
		}
	});
}

function trim(str) {
	return str.replace(/^\s*(.*?)[\s\n]*$/g, '$1');
}
</script>
            </form>
     </div>
     
</div>
            
</div></div>